import { Injectable } from '@angular/core';
import {BadgeComponent, BadgePipe, SimpleJsonFormatter, SimplePipe} from '../../../ng-tools';
import {DatePipe} from '@angular/common';

@Injectable({
  providedIn: 'root'
})
export class MoneyRecordFormatterService {
  nickname: SimpleJsonFormatter = {propName: 'nickname', displayName: '用户名'};
  fromUserName: SimpleJsonFormatter = {propName: 'userId', displayName: '用户ID'};
  type_display: SimpleJsonFormatter = {propName: 'type_display', displayName: '提现类型'};
  toUserName: SimpleJsonFormatter = {propName: 'toUserName', displayName: '提现人姓名'};
  toNumber: SimpleJsonFormatter = {propName: 'toNumber', displayName: '提现账号'};
  createDate: SimpleJsonFormatter = {propName: 'createDate', displayName: '申请时间'};
  doneDate: SimpleJsonFormatter = {propName: 'createDate', displayName: '完成时间'};
  account: SimpleJsonFormatter = {propName: 'account', displayName: '提现金额'};
  status_display: SimpleJsonFormatter = {propName: 'status_display', displayName: '状态', dynamicComponent: {component: BadgeComponent}, component: BadgeComponent};
  constructor(public badgePipe: BadgePipe, private datePipe: DatePipe ) {
    this.status_display.pipe = new SimplePipe(this.badgePipe, [['待审核', '已确认', '已取消'], ['badge-orange', 'badge-success', 'badge-danger']]);
    this.createDate.pipe = new SimplePipe(this.datePipe, ['yyyy-MM-dd HH:mm:ss', null, null, null]);
    this.doneDate.pipe = new SimplePipe(this.datePipe, ['yyyy-MM-dd HH:mm:ss', null, null, null]);
  }
  get formatter() {
    return [
      this.nickname,
      this.fromUserName,
      this.type_display,
      this.toUserName,
      this.toNumber,
      this.createDate,
      this.account,
      this.status_display
    ];
  }

  get doneFormatter() {
    return [
      this.nickname,
      this.fromUserName,
      this.type_display,
      this.toUserName,
      this.toNumber,
      this.doneDate,
      this.account,
      this.status_display
    ];
  }
}
